package com.usian.admin.controller;

import com.usian.admin.service.AdChannelService;
import com.usian.admin.service.AdSensitiveService;
import com.usian.apis.admin.AdChannelControllerApi;
import com.usian.apis.admin.AdSensitiveControllerApi;
import com.usian.model.admin.dtos.ChannelDto;
import com.usian.model.admin.pojos.AdChannel;
import com.usian.model.admin.pojos.AdSensitive;
import com.usian.model.common.dtos.ResponseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/v1/sensitive")
@Api(value = "敏感词设置",tags = "AdSensitive",description = "频道模块的api接口")
public class AdSensitiveController implements AdSensitiveControllerApi {
    @Autowired
    private AdSensitiveService adSensitiveService;

    //RequestBody  前端以json格式提交   后台自动反序列化
    @PostMapping("/list")
    @Override
    @ApiOperation(value = "查询敏感词",notes = "根据名称分页查询敏感词")
    @ApiImplicitParam(name = "dto",type ="ChannelDto",value = "查询敏感词")
    public ResponseResult findByNameAndPage(@RequestBody ChannelDto dto){
        return adSensitiveService.findByNameAndPage(dto);
    }

    @RequestMapping("/save")
    @Override
    public ResponseResult save(@RequestBody AdSensitive adSensitive) {
        return adSensitiveService.insert(adSensitive);
    }

    @RequestMapping("/update")
    @Override
    public ResponseResult update(@RequestBody AdSensitive adSensitive) {
        return adSensitiveService.update(adSensitive);
    }

    @RequestMapping("/del/{id}")
    @Override
    public ResponseResult del(@PathVariable("id") Integer id) {
        return adSensitiveService.del(id);
    }
}
